package Controller;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Entity.Book;
import Services.WebService;

public class HomeServlet extends BaseHttpServlet {
    @Override    
    protected void processRequest(HttpServletRequest request, HttpServletResponse response, WebService webServices, String action) throws ServletException, IOException {
//    	ArrayList<Book> mostViewedBooks = webServices.getEntityManager().getMostViewedBooks();
//    	ArrayList<Book> mostPurchasedBooks = webServices.getEntityManager().getMostPurchasedBooks();
//    	
//    	request.setAttribute("mostViewedBooks", mostViewedBooks);
//    	request.setAttribute("mostPurchasedBooks", mostPurchasedBooks);
    	
    	ArrayList<Book> bookList = webServices.getEntityManager().getBooks();
    	request.setAttribute("books", bookList);
    	
    	this.forward(request, response, webServices, action, "/index.jsp");
    }
}